# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=ghauri
pkgver=1.4.3.r0.g18e3677
pkgrel=1
pkgdesc='An advanced cross-platform tool that automates the process of detecting and exploiting SQL injection security flaws.'
arch=('any')
groups=('blackarch' 'blackarch-webapp' 'blackarch-exploitation')
url='https://github.com/r0oth3x49/ghauri'
license=('MIT')
depends=('python')
makedepends=('git' 'python-setuptools' 'python-pip')
source=("git+https://github.com/r0oth3x49/$pkgname.git")
sha512sums=('SKIP')
install="$pkgname.install"

pkgver() {
  cd $pkgname

  ( set -o pipefail
    git describe --long --tags --abbrev=7 2>/dev/null |
      sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
    printf "%s.%s" "$(git rev-list --count HEAD)" \
      "$(git rev-parse --short=7 HEAD)"
  )
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -Dm 644 requirements.txt "$pkgdir/usr/share/$pkgname/requirements.txt"
  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" *.md

  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm -rf LICENSE *.md docs/*.md .gitignore .github/

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
source /usr/share/$pkgname/venv/bin/activate
exec $pkgname "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

